<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
		#allmap{width:100%;height:500px;}
		#r-result{width:100%;margin-top:5px;}
		p{margin:5px; font-size:14px;}
	</style>
    <script type="text/javascript" src="../baidujs/baidu.js"></script>
    <script type="text/javascript" src="../baidujs/modules.js"></script>
	<title>添加清华校园微观图</title>
</head>
<body>
	<div id="allmap"></div>
	<div id="r-result">
		<input type="button" onclick="add_control();" value="添加" />
		<input type="button" onclick="delete_control();" value="删除" />
	</div>
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map('allmap');
	map.addControl(new BMap.NavigationControl());
	map.centerAndZoom(new BMap.Point(116.332782, 40.007978), 16);
	var tileLayer = new BMap.TileLayer({isTransparentPng: true});
	tileLayer.getTilesUrl = function(tileCoord, zoom) {
		var x = tileCoord.x;
		var y = tileCoord.y;		
        if(x == 12647 && y == 4725){
           return '../baiduimages/m0.png';  //根据当前坐标，选取合适的瓦片图
        }    
        return 'http://developer.baidu.com/map/jsdemo/demo/tiles/' + zoom + '/tile' + x + '_' + y + '.png';  //根据当前坐标，选取合适的瓦片图
	}

	var copyCtrl = new BMap.CopyrightControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT});
	copyCtrl.addCopyright({id: 1, content: "版权说明：清华校园图片取自互联网"});
	map.addControl(copyCtrl);
	
	function add_control(){
		map.addTileLayer(tileLayer);
	}
	function delete_control(){
		map.removeTileLayer(tileLayer);
	}
	add_control();
</script>
